if(NOT "${GMP_LIBRARY_TYPE}" STREQUAL "STATIC" AND NOT "${GMP_LIBRARY_TYPE}" STREQUAL "SHARED")
    set(GMP_LIBRARY_TYPE "@GMP_LIBRARY_TYPE@")
endif()
set(LIB_PREFIX "${CMAKE_${GMP_LIBRARY_TYPE}_LIBRARY_PREFIX}")
set(LIB_SUFFIX "${CMAKE_${GMP_LIBRARY_TYPE}_LIBRARY_SUFFIX}")

set(GMP_INCLUDE_PATHS "@INSTALL_CONFIG_INCLUDE_PATHS@")
set(GMP_LIB_PATHS "@INSTALL_CONFIG_LIB_PATHS@")

unset(GMP_INCLUDE_DIR CACHE)
unset(GMP_LIBRARY CACHE)

find_path(GMP_INCLUDE_DIR gmp.h PATHS ${GMP_INCLUDE_PATHS})
find_library(GMP_LIBRARY NAMES ${LIB_PREFIX}gmp${LIB_SUFFIX} PATHS ${GMP_LIB_PATHS})

if(EXISTS "${GMP_INCLUDE_DIR}" AND EXISTS "${GMP_LIBRARY}")
    set(GMP_FOUND TRUE)
else()
    set(GMP_LIBRARY )
    set(GMP_FOUND FALSE)
endif()

if(GMP_FOUND AND NOT TARGET GMP::GMP)
    add_library(GMP::GMP "${GMP_LIBRARY_TYPE}" IMPORTED)
    set_target_properties(GMP::GMP PROPERTIES 
                              IMPORTED_LOCATION "${GMP_LIBRARY}"
                              INTERFACE_INCLUDE_DIRECTORIES "${GMP_INCLUDE_DIR}")
endif()

mark_as_advanced(
    GMP_INCLUDE_DIR
    GMP_LIBRARY
)
